
package com.scalar.chiptrack.users;


public final class LevelAccess {
    
    private int m_levelId = -1;
    private int m_groupId = -1;
    private int m_functionId = -1;
    
    private boolean m_viewAllowed = false;
    private boolean m_modifyAllowed = false;
    private boolean m_deleteAllowed = false;
    
    public LevelAccess() {
    }
    
    public LevelAccess (int levelId, int groupId, int functionId, boolean view, boolean modify, boolean delete) {
        m_levelId = levelId;
        m_groupId = groupId;
        m_functionId = functionId;
        
        m_viewAllowed = view;
        m_modifyAllowed = modify;
        m_deleteAllowed = delete;
    }
    
    public int getLevelId() {
        return m_levelId;
    }
    public void setLevelId (int id) {
        m_levelId = id;
    }
    
    public int getGroupId() {
        return m_groupId;
    }
    public void setGroupId (int id) {
        m_groupId = id;
    }
    
    public int getFunctionId() {
        return m_functionId;
    }
    public void setFunctionId (int functionId) {
        m_functionId = functionId;
    }
    
    public boolean getView() {
        return m_viewAllowed;
    }

    public boolean getView (int funcId) {
        if (funcId == m_functionId) {
            return m_viewAllowed;
        }
        
        return false;
    }

    public void setView (boolean flag) {
        m_viewAllowed = flag;
    }
    
    public boolean getModify() {
        return m_modifyAllowed;
    }

    public boolean getModify (int funcId) {
        if (funcId == m_functionId) {
            return m_modifyAllowed;
        }
        
        return false;
    }

    public void setModify (boolean flag) {
        m_modifyAllowed = flag;
    }
    
    public boolean getDelete() {
        return m_deleteAllowed;
    }
    
    public boolean getDelete (int funcId) {
        if (funcId == m_functionId) {
            return m_deleteAllowed;
        }
        
        return false;
    }

    public void setDelete (boolean flag) {
        m_deleteAllowed = flag;
    }
    
    
    public String toString() {
        return "LevelAccess: Level_ID = " + m_levelId + ", Group_ID = " + m_groupId + ", Function_ID = " + m_functionId + ", View = " + m_viewAllowed + ", Modify = " + m_modifyAllowed + ", Delete = " + m_deleteAllowed;
    }
    
}